/*
 *  SableJBDD, a Java Binary Decision Diagram package.
 *  Copyright (C) 2003  Feng Qian
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
//$Id: JBddConstNode.java,v 1.5 2004/06/03 03:54:01 fqian Exp $

package SableJBDD.bdd;
/**
 * JBddConstNode defines ZERO and ONE constant bdd nodes.
 *
 * @author Feng Qian
 */

final class JBddConstNode extends JBddNode implements JBddConstants {
  private static JBddVariable constvar = new JBddVariable("const", MAX_LEVEL);
  private static JBddNode zero = new JBddConstNode(0);
  private static JBddNode one = new JBddConstNode(1);
  private int value;

  /**
   * @return the canonical ONE node
   */
  public static JBddNode ONE() { return one; }
  /**
   * @return the canonical ZERO node
   */
  public static JBddNode ZERO() { return zero; }

  private JBddConstNode() {}
  private JBddConstNode(int v) {
    this.value = v;
    this.variable = constvar;
  }

  // overrides superclass's method
  boolean isConst() {
    return true;
  }

  // overrides super class's 
  int getLevel() {
    return MAX_LEVEL;
  }

  public String toString() {
    return ""+this.value;
  }
}
